home *** CD-ROM | disk | FTP | other *** search
- unit ProgressFrm;
-
- interface
- {$D-}
- uses
- Windows, Classes, SysUtils, Controls, Forms, Gauges, StdCtrls, ExtCtrls;
-
- type
- EProgressError=Exception;
-
- TfrmProgress = class(TForm)
- Gauge1: TGauge;
- Label1: TLabel;
- Bevel1: TBevel;
- procedure FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- procedure FormShow(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- function GetMax:LongInt;
- function GetProgress:LongInt;
- procedure SetMax(value:LongInt);
- procedure SetProgress(value:LongInt);
- protected
- procedure SetDesc(const value:string);
- function GetDesc:string;
- public
- { Public declarations }
- procedure Inc;
- published
- property Max:Longint read GetMax write SetMax default 100;
- property Progress:LongInt read GetProgress write SetProgress;
- property JobDescription:string read GetDesc write SetDesc;
- end;
-
- var
- frmProgress: TfrmProgress;
-
- implementation
-
- {$R *.DFM}
-
- procedure TfrmProgress.SetDesc(const value:string);
- begin
- Label1.Caption:=value;
- end;
-
- function TfrmProgress.GetDesc:string;
- begin
- result:=Label1.Caption;
- end;
-
- function TfrmProgress.GetMax:LongInt;
- begin
- Result:=Gauge1.MaxValue;
- end;
-
- function TfrmProgress.GetProgress:LongInt;
- begin
- Result:=Gauge1.Progress;
- end;
-
- procedure TfrmProgress.Inc;
- begin
- SetProgress(Gauge1.Progress+1);
- end;
-
- procedure TfrmProgress.SetProgress(value:LongInt);
- begin
- Gauge1.Progress:=Value;
- Application.ProcessMessages;
- end;
-
- // This procedure is provided for hooking to Apollo.
- procedure TfrmProgress.FormKeyDown(Sender: TObject; var Key: Word;
- Shift: TShiftState);
- var
- wVal : Word;
- begin
- if (Key and $7000) <> 0 then
- begin
- wVal := -Word( Key );
- Gauge1.Progress := wVal;
- Application.ProcessMessages;
- Key := 0;
- end;
- end;
-
- procedure TfrmProgress.SetMax(value:LongInt);
- begin
- if not (value>0) then
- raise EProgressError.Create('Progress Bar Range: Max <= 0');
- Gauge1.MaxValue:=Value;
- end;
-
- procedure TfrmProgress.FormShow(Sender: TObject);
- begin
- Left:=Screen.Width-Width-10;
- Top:=Screen.Height-Height-10;
- Gauge1.Progress:=0;
- application.processmessages;
- end;
-
- procedure TfrmProgress.FormCreate(Sender: TObject);
- begin
- Gauge1.MaxValue:=100;
- end;
-
- end.
-